# Maintainer: Bruno Pagani <archange@archlinux.org>
# Contributor: Hector Mtz-Seara <hseara.#at#.gmail*.*com>

pkgname=pyzo
pkgver=4.12.4
pkgrel=2
pkgdesc="Cross-platform Python IDE focused on interactivity and introspection, very suitable for scientific computing."
arch=(any)
url="https://pyzo.org"
license=(BSD)
depends=(python-packaging)
makedepends=(python-setuptools)
optdepends=(
    'pyside2: Qt5 backend'
    'pyside6: Qt6 backend'
    'python-pyqt5: alternative Qt5 backend'
    'python-pyqt6: alternative Qt6 backend'
)
checkdepends=(python-pytest pyside2 pyside6 python-pyqt5 python-pyqt6 xorg-server-xvfb)
source=(https://github.com/pyzo/pyzo/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('d864761759bc8516498bc3f09bc29c91f400078746b656c69a76391b6b0e917f')

build() {
    cd ${pkgname}-${pkgver}
    python setup.py build
}

check() {
    cd ${pkgname}-${pkgver}
    python -m venv --system-site-packages test-env
    test-env/bin/python setup.py install --skip-build
    test-env/bin/python -m pytest -v --color=yes tests
    xvfb-run --auto-servernum test-env/bin/python pyzolauncher.py --test
    test-env/bin/python tests/check_log.py
}

package() {
    cd ${pkgname}-${pkgver}
    python setup.py install --root="${pkgdir}" --optimize=1 --skip-build

    # Clean
    rm "${pkgdir}"/usr/{LICENSE.md,README.md,pyzo.appdata.xml,pyzolauncher.py}
    install -Dm644 LICENSE.md -t "${pkgdir}"/usr/share/licenses/${pkgname}/
    install -Dm644 pyzo.appdata.xml -t "${pkgdir}"/usr/share/metainfo/
    install pyzolauncher.py "${pkgdir}"/usr/bin/pyzo

    install -Dm644 pyzo/resources/pyzo.desktop -t "${pkgdir}"/usr/share/applications/
    for i in 16 32 48 64 128 256 ; do
        install -Dm644 pyzo/resources/appicons/pyzologo${i}.png "${pkgdir}"/usr/share/icons/hicolor/${i}x${i}/apps/pyzologo.png
    done
}
